#include "InventorySystem.hpp"
#include <GQE/Entity/classes/Instance.hpp>
#include <tinyxml.h>
InventorySystem::InventorySystem(GQE::IApp& theApp):
  ISystem("InventorySystem",theApp),
  mItem("Item",3),
  mSelectedItem(0),
  mPlayer(NULL),
  mItemTileset("resources/Images/Items.png",GQE::AssetLoadNow),
  mItemIcons("resources/Images/ItemIcons.png",GQE::AssetLoadNow)
{

}
InventorySystem::~InventorySystem()
{

}
void InventorySystem::AddProperties(GQE::IEntity* theEntity)
{
  theEntity->mProperties.Add<bool>("bItem",true);
  theEntity->mProperties.Add<GQE::Uint32>("uItemID",0);
  theEntity->mProperties.Add<std::string>("sName","");
  theEntity->mProperties.Add<std::string>("sInfo","");
  theEntity->mProperties.Add<GQE::Uint32>("uImageID",0);
}
void InventorySystem::AddPlayer(GQE::IEntity* thePlayer)
{
  if(thePlayer!=NULL)
  {
    mPlayer=thePlayer;
    mPlayer->mProperties.Add<typeInventory>("Inventory",typeInventory());
  }
}
void InventorySystem::HandleInit(GQE::IEntity* theEntity)
{
}


void InventorySystem::HandleEvents(sf::Event theEvent)
{
}

void InventorySystem::UpdateFixed()
{

}

void InventorySystem::UpdateVariable(float theElaspedTime)
{
}

void InventorySystem::Draw()
{

}

void InventorySystem::HandleCleanup(GQE::IEntity* theEntity)
{
}

void InventorySystem::AddItem(std::string theItemName, std::string theItemInfo, typeEffectList theEffects)
{
  typeItemData anData;
  anData.id=mItemDataList.size();
  anData.name=theItemName;
  anData.info=theItemInfo;
  anData.effects=theEffects;
}
void InventorySystem::AddItems(std::string theItemFile)
{

}
void InventorySystem::GiveItem(GQE::Uint32 theItemId)
{
  if(theItemId>0)
  {
    typeInventory anInventory=mPlayer->mProperties.Get<typeInventory>("Inventory");
    anInventory.push_back(theItemId);
    mPlayer->mProperties.Set<typeInventory>("Inventory",anInventory);
  }
}
void InventorySystem::DropItem(GQE::Uint32 theItemIndex)
{
  typeInventory anInventory=mPlayer->mProperties.Get<typeInventory>("Inventory");
  anInventory.erase(anInventory.begin()+theItemIndex);
  mPlayer->mProperties.Set<typeInventory>("Inventory",anInventory);
}
void InventorySystem::SelectItem(GQE::Uint32 theItemIndex)
{

}
